using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace Engine.WindowsFormsControls
{
    public partial class AskForReplacingTexture : Form
    {
        #region Public Constructors

        public AskForReplacingTexture()
        {
            InitializeComponent();
        }

        #endregion Public Constructors

        #region Public Properties

        public int SelectedTextureID
        {
            get
            {
                return this.comboBox1.SelectedIndex;
            }
        }

        #endregion Public Properties

        #region Public Methods

        public void SetMissingTextureName(string textureName)
        {
            this.textBox1.Text = textureName;
        }

        public void SetTextureNames(List<string> textureNames)
        {
            this.comboBox1.DataSource = textureNames;
            if (textureNames.Count > 0)
                this.comboBox1.SelectedIndex = 0;
        }

        #endregion Public Methods

        #region Private Methods

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBox comboBox = (ComboBox)sender;
            if (this.Visible)
            {
                try
                {
                    this.panel1.BackgroundImage = Ptx2bmpConverter.Ptx2bmp.FromFile(Application.StartupPath + "\\texture\\" + comboBox.SelectedItem + ".ptx");
                }
                catch (Exception ex)
                {
                    this.panel1.BackgroundImage = null;
                    MessageBox.Show(ex.Message);
                }
            }
        }

        #endregion Private Methods
    }
}